// import type { EditType } from '../StongTable/type';
import type { Widget } from './type';

export type EditType =
  | 'string'
  | 'input'
  | 'number'
  | 'select'
  | 'switch'
  | 'radio'
  | 'checkbox'
  | 'date'
  | 'modal';
/** 精确查询 */
export const PRECISE_SEARCH = 0;
/** 模糊查询 */
export const FUZZY_SEARCH = 1;
/** 范围查询 */
export const RANGE_SEARCH = 2;
/** 可搜索的表单组件类型 */
export const searchWidgets: Widget[] = [
  'select',
  'checkboxes',
  'radio',
  'input',
  'date',
  'time',
  'number',
  'switch',
];

export const searchTypeConfig = {
  [PRECISE_SEARCH]: {
    widgets: ['select', 'checkboxes', 'radio'],
    text: '精确查询',
  },
  [FUZZY_SEARCH]: {
    widgets: ['input', 'textarea'],
    text: '模糊查询',
  },
  [RANGE_SEARCH]: {
    widgets: ['date', 'time', 'number'],
    text: '范围查询',
  },
};

/** StongTable 表格编辑类型 映射 TableFilter 表单类型 */
export const editWidgetConfigs: { [key in EditType]?: Widget } = {
  string: 'input',
  number: 'number',
  select: 'select',
  modal: 'input',
  input: 'input',
  radio: 'radio',
  date: 'date',
  switch: 'switch',
  checkbox: 'checkboxes',
};
/** TableFilter 表单类型 映射 StongTable 表格编辑类型 */
export const widgetEditConfigs: { [key in Widget]?: EditType } = {
  input: 'string',
  number: 'number',
  select: 'select',
  radio: 'radio',
  date: 'date',
  switch: 'switch',
  checkboxes: 'checkbox',
};
